package com.mxpio.erp.common.util;

import com.fasterxml.jackson.databind.ObjectMapper;

public class CloneUtil {


    private static final ObjectMapper mapper = new ObjectMapper();

    public static <T> T deepClone(T object, Class<T> clazz) {
        try {
            String json = mapper.writeValueAsString(object);
            return mapper.readValue(json, clazz);
        } catch (Exception e) {
            throw new RuntimeException("Deep clone failed", e);
        }
    }

}
